<template>
  <view>
    <view class="wrap">
		 
		<view class="top_select">
			<view class="top_type" v-for="(item,index) in toplist" :key="index" :class=" index==selectorderindex?'select-type':''" @click="selectorderfun(index)" v-if="index!=2">
				{{item.name}}
			</view>
		</view>
      <view class="u-tabs-box">
		 <u-tabs :list="list" :scrollable="true"
		 lineColor="#FFFFFF"
		  :activeStyle="{
		              color: '#FA623D',
		          }"
		  :inactiveStyle="{
				              color: '#939393',
				          }"
		  :current="current" @click="change"></u-tabs>
      </view>
      <u-modal
        :show="showModel"
        @confirm="confirm"
		@cancel="cancelfun"
        title="温馨提示"
        ref="uModal"
        :async-close="true"
        :content="showModelContent"
        :show-cancel-button="true"
      ></u-modal>
	  
	  
      <swiper
        class="swiper-box"
        :current="swiperCurrent"
        @transition="transition"
        @animationfinish="animationfinish"
      >
        <!--       全部 -->
        <swiper-item class="swiper-item" v-for="(f, i) in list" :key="i">
          <scroll-view
            scroll-y
            style="height: auto; width: 100% ;"
            :lower-threshold="10"
            class="scroll_wrapper"
			 @scrolltolower="lower"
          >
           
			<view class="order-k" v-for="(item,index) in orderList" :key="index" @click="orderToggle(item)">
				<view class="order-title">
					<view class="order-title-left" v-if="selectorderindex==1">
						{{"商品信息"}}
					</view>
					<view class="order-title-left" v-if="selectorderindex==0">
						{{item.packageName}}
					</view>
					<view class="order-title-right" v-if="selectorderindex==1">
						<!-- 已付款
						订单状态 -1:已取消 0:待付款 1:待发货 2:待收货 3:已完成 -->
						{{item.orderStats==-1?"已取消":item.orderStats==0?"待付款":item.orderStats==1?"待发货":item.orderStats==2?"待收货":item.orderStats==3?"已完成":""}}
					</view>
					<view class="order-title-right" v-if="selectorderindex==0">
						<!-- 已付款
						订单状态 -1:已取消 0:待付款 1:待发货 2:待收货 3:已完成 -->
						{{item.orderStats==-1?"已取消":item.orderStats==0?"待付款":item.orderStats==1?"待服务":item.orderStats==2?"已服务":item.orderStats==3?"待评价":""}}
					</view>
				</view>
				<view class="order-info" v-for="(items,index) in item.items" :key="index" v-if="selectorderindex==1"> 
					<view class="order-info-k">
						
					
					<view class="order-info-icon">
						<image :src="items.dataSource==1?items.goodsImage:httpUrlFn(items.goodsImage)" ></image>
					</view>
					<view class="order-info-content">
						<view class="order-info-name">{{items.goodsName}}</view>
						<view class="order-info-content-time order-info-content-time-shop" >
							<view class="order-info-content-time-shop-left">
								规格数量：
							</view>
							<view>
								{{items.goodsSpec}} 
							</view>
							
						</view>
						<view class="order-info-content-mrs shop-order-info-content-mrs">
							<text>价格：￥{{items.goodsPrice}}</text> <text class="shop-order-info-content-mrs-text"> X{{items.goodsNumber}}</text>
						</view>
					</view>
					</view>
					<view class="order-shouh" v-if="item.orderStats==1||item.orderStats==2||item.orderStats==3">
						<view class="order-shouh-item" v-if="items.saleStatus==0"  @click.stop="cancellationFn(items,index,5)">
							申请售后
						</view>
						<view class="order-shouh-item order-shouh-item-true" v-if="items.saleStatus==1"  >
							售后中
						</view>
						<view class="order-shouh-item order-shouh-item-true" v-if="items.saleStatus==2"  >
							售后完成
						</view>
					</view>
					
				</view>
				
				<view class="order-info order-pages-info" v-if="selectorderindex==0" >
					<view class="order-info-icon">
						<image :src="httpUrlFn(item.packageImage)" ></image>
					</view>
					<view class="order-info-content">
						<view class="order-info-content-time">
							预约时间：{{item.schedulDate}} {{item.timeSection}}
						</view>
						<view class="order-info-content-mrs">
							美容师：{{item.teamName}}/{{item.shopName}}
						</view>
					</view>
					
				</view>
				<view class="order-num" v-if="selectorderindex==2">
					<view>￥</view>
					<view>{{item.totalAmount}}</view>
					<!-- <view>起</view> -->
				</view>
				
				<view class="order-num order-num-shop" v-if="selectorderindex==1">
					<view class="order-num-sl">
						<view>￥</view>
						<view>{{item.allPrice}}</view>
						<!-- <view>起</view> -->
					</view>
					<view class="order-num-time">
						下单时间{{item.orderTime}}
					</view>
					
				</view>
				<view class="order-czbt" v-if="selectorderindex==0">
					<!-- <view class="order-czbt-item" v-if="item.orderStats==-1" @click.stop="cancellationtwoFn(item, index, -1)">
						删除订单
					</view> -->
					<view class="order-czbt-item" v-if="item.orderStats==0" @click.stop="cancellationtwoFn(item, index, 4)">
						取消支付
					</view>
					<view class="order-czbt-item" v-if="items.saleStatus==0||item.orderStats==1"  @click.stop="cancellationtwoFn(item,index,5)">
						申请退款
					</view>
					<view class="order-czbt-item" v-if="item.orderStats==0" @click.stop="paymentFn(item,index)">
						立即支付
					</view>
					
					
				</view>
				<view class="order-czbt" v-if="selectorderindex==1">
					<view class="order-czbt-item" v-if="item.orderStats==-1" @click.stop="cancellationFn(item, index, -1)">
						删除订单
					</view>
					<view class="order-czbt-item" v-if="item.orderStats==0" @click.stop="cancellationFn(item, index, 4)">
						取消支付
					</view>
					<view class="order-czbt-item" v-if="item.orderStats==2" @click.stop="logisticsFn(item, index)">
						查看物流
					</view>
					<view class="order-czbt-item" v-if="item.orderStats==2" @click.stop="cancellationFn(item, index, 3)">
						确认完成
					</view>
					<view class="order-czbt-item" v-if="item.orderStats==0" @click.stop="paymentFn(item,index)">
						立即支付
					</view>
					
					
				</view>
			</view>
            <view
              style="display: flex; justify-content: center; padding: 30rpx"
              class="none_shopping"
              v-if="orderList.length === 0&&showlogin"
            >
              <image src="/static/None/None_shopping.png"></image>
              <text>暂无订单喔~</text>
            </view>
           
			
            <u-loadmore
              v-if="orderList.length > 0 "
              :status="status"
              :icon-type="iconType"
              :load-text="loadText"
              @loadmore="loadNextFn"
              class="loadmore_wrapper"
            />
          </scroll-view>
        </swiper-item>
      </swiper>
    </view>
  </view>
</template>

<script>
import {
  getGoodsOrderPage,
  cancelGoodsOrder,
  delGoodsOrder,
  confirmGoodsOrderArrival,
  payOrderCallbackTest,
 
  // 门店操作
  cancelPackageOrderPay,
   getPackageOrderPage,
  
  cancelApi,
  orderInfoByTypeAndStatus,
  updateOrderStatusByOrderSn,
  weixinPay,
} from "@/api/orderApi";
import { BASE_URL_IMAHE } from "../../../../utils/https";
import { randomDerate } from "@/api/address";

export default {
  watch: {
    swiperCurrent(newValue, oldValue) {
		console.log("呢哇",newValue,oldValue)
      this.order.pageSize = 10;
      this.order.pageNo = 1;
      this.orderList = [];
      // this.myOrder();
	  if(this.selectorderindex==0){
	  			 
				 this.myPackageOrder()
				 
	  }
	  if(this.selectorderindex==1){
	  			  // this.order.pageNo=1
	  			 this.myOrder(); 
	  }
	  if(this.selectorderindex==2){
	  			  // this.order.pageNo=1
	  			 // this.myPackageOrder()
				 this.orderList=[]
	  }
      console.log(newValue, "新的");
      console.log(oldValue, "旧的");
    },
  },
  data() {
    return {
      //订单更新状态用
      orderUpdata: {},
      //原数组
      orderList: {
        // records: [],
      },
      //用于条件渲染的数组
      orderFilter: [],
      bac: {
        background: "red",
      },
      status: "loadmore",
      iconType: "flower",
      loadText: {
        loadmore: "点击加载更多",
        loading: "正在加载，请喝杯茶...",
        nomore: "哼~😕我也是有底线的~",
        //哼~😕我也是有底线的~
        //😕我也是有底线的~
      },
      page: 0,
      pageSize: 20,
      show: false,
	  showlogin:true,
      list: [
        
      ],
	  list1:[
		  {
		    name: "全部",
		  },
		  {
		    name: "待支付",
		  },
		  {
		    name: "待服务",
		  },
		  {
		    name: "已服务",
		  },
		  {
		    name: "待评价",
		  },
		  {
		    name: "已取消",
		  },
	  ],
	  list2: [
	    {
	      name: "全部",
	    },
	    {
	      name: "待支付",
	    },
	    {
	      name: "待发货",
	    },
	    {
	      name: "已发货",
	    },
		{
		  name: "已完成",
		},
		
	    {
	      name: "已取消",
	    },
	  ],
	  selectorderindex:0,
	  toplist:[
		 {name:"门店订单"},
		 {name:"商城订单"},
		 {name:"权益卡订单"}
	  ],
      orderType: [],
      // 因为内部的滑动机制限制，请将tabs组件和swiper组件的current用不同变量赋值
      current: 0, //tabs组件的current值，表示当前活动的tab选项
      swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
      tabsHeight: 0,
      dx: 0,
      showModel: false,
      showModelContent: "确定要取消订单吗？",
      options: null,
      order: {
		 userId:"",
		  // v:"",
		// payStats:"",
        // orderType: "", //1->普通订单；2->礼包订单；3->兑换订单;
        orderStats: "1", //状态0、待付款 1、待发货 2、待收货 3、已完成 4、已关闭
        pageNo: 1,
        //条数
        pageSize: 10,
      },
	  pagenum:1,
    };
  },
  onLoad(options) {
	this.order.userId=uni.getStorageSync("userId")

	

    console.log(options, "传递过来的");
	// 
	this.order.pageSize = 10;
	this.order.pageNo = 1;
	this.orderList = [];
	if(options.type==1){
		this.list=this.list2
		
	}else if(options.type==0){
		this.list=this.list1
	}
	this.selectorderindex=options.type

	this.options=options.status?options.status:0
	this.show = true;
	this.current = +this.options || 0;
	this.order.pageNo = 1;
	 this.orderList=[]
	if (this.options == 0) {
	  this.swiperCurrent = +this.options || 0;
	  // if(this.selectorderindex==1){
		 //  this.myOrder();
	  // }else{
		 //  this.myPackageOrder()
	  // }
	 
	} else {
	  this.swiperCurrent = +this.options || 0;
	}
	
	
  },
  onShow() {
	  this.orderList=[]
	  if(this.selectorderindex==1){
	  		  this.myOrder();
	  }else{
	  		  this.myPackageOrder()
	  }
    
  },
  //上拉
  onReachBottom() {
    console.log("触发上拉加载");
	
    //请求订单
	if(this.selectorderindex==0){
		
		this.myPackageOrder();
	}
	if(this.selectorderindex==1){
		this.myOrder();
	}
    
  },
  methods: {
	  
	  lower(){
	  	console.log('滚动到底部')
	  	// this.page ++
	  	// this.getList()
		//请求订单
			console.log(this.pagenum,this.order.pageNo,"dssadsasda")
		if(this.pagenum>=this.order.pageNo){
			if(this.selectorderindex==0){
				
				this.myPackageOrder();
			}
			if(this.selectorderindex==1){
				this.myOrder();
			}
		}
		
	  },
	  selectorderfun(index){
		  this.order.pageNo=1
		  if(this.selectorderindex==index){
			  return
		  }
		  this.orderList = [];
		  this.selectorderindex=index
		  if(index==0){
			  this.list=this.list1
		  }else if(index==1){
			  this.list=this.list2
		  }
		  this.current=0
		  this.swiperCurrent=0
		  if(index==0){
			  this.order.pageNo=1
			 this.myPackageOrder()
		  }
		  if(index==1){
			  this.order.pageNo=1
		  			 this.myOrder(); 
		  }
		  
	  },
	  goshouhfundet(item){
		  uni.navigateTo({
		  	url:`/pages/subpackage/apply_afterSaledet/index?order=${encodeURIComponent(
          JSON.stringify(item)
        )}&status=1`
		  })
	  },
    //b页面返回到a页面的参数
    otherFun(object) {
      console.log(object, "object123");
      if (object) {
        console.log(object);
        this.current = object.current;
        if (object.swiperCurrent === 0) {
          this.swiperCurrent = object.swiperCurrent;
          this.myOrder();
        } else {
          this.swiperCurrent = object.swiperCurrent;
        }
      }
    },

    //点击订单详情
    orderToggle(item) {
		if(this.selectorderindex==0){
			uni.navigateTo({
			  url: `/pages/subpackage/orderDetails/shoporder?order=${encodeURIComponent(
			    JSON.stringify(item)
			  )}&status=1`,
			});
			
		}else if(this.selectorderindex==1){
			uni.navigateTo({
			  url: `/pages/subpackage/orderDetails/index?order=${encodeURIComponent(
			    JSON.stringify(item)
			  )}&status=1`,
			});
			
		}
      
    },

    httpUrlFn(item) {
      if (item) {
        return BASE_URL_IMAHE + item;
      }
      
    },

    //立即支付
    async paymentFn(item, index) {
		// 打开支付宝支付
		uni.requestPayment({
		    provider: 'alipay',
		    orderInfo: item.tradeNo, //支付宝订单数据
		    success: function(res_alipay) {
									 if(res_alipay.resultCode=="9000"){
										 uni.showToast({
										   title: "支付成功",
										   icon: "success",
										   duration: 2000,
										 });
										 
										 setTimeout(() => {
										   uni.redirectTo({
										     url: "/pages/subpackage/order/index?status=2&type=1",
										   });
										 }, 1000);
									 }else{
										
										uni.showToast({
										  title: "支付失败",
										  icon: "error",
										  duration: 2000,
										});
										 setTimeout(() => {
										   uni.redirectTo({
										     url: "/pages/subpackage/order/index?status=1&type=1",
										   });
										 }, 1000);
										
									 }
		    },
								 fail(rej) {
								 	console.log("rej",rej)
								 }
		})
      
    //     if (res.result == 0) {
    //       uni.showToast({
    //         title: "支付成功",
    //         icon: "success",
    //         duration: 2000,
    //       });
		  // await this.myOrder();
    //     } else {
    //       uni.showToast({
    //         title: "支付订单错误",
    //         icon: "success",
    //         duration: 2000,
    //       });
    //       return;
        
    //     //end
    //   }
     
      // }
    },
	// 门店订单
	
	async myPackageOrder() {
	  this.status = "loading";
	  this.showlogin=false
	   //获取订单的状态
	   if(this.swiperCurrent==0){
		    this.order.orderStats="" 
	   }else if(this.swiperCurrent==1){
		   this.order.orderStats=0
	   }
	   else if(this.swiperCurrent==2){
	   		   this.order.orderStats=1
	   }
	   else if(this.swiperCurrent==3){
	   		   this.order.orderStats=2
	   }
	   else if(this.swiperCurrent==4){
	   		   this.order.orderStats=3
	   }
	   else if(this.swiperCurrent==5){
	   		   this.order.orderStats=-1
	   }
	  const res = await getPackageOrderPage(JSON.stringify(this.order));
	  if (res.result == 0) {
	    this.show = true;
		this.showlogin=true
	    //保存原数组
	    // this.orderList = res.page.list;
		this.orderList.push(...res.page.list);
		console.log(this.orderList)
		this.pagenum=Math.ceil(res.page.count/this.order.pageSize)
		this.order.pageNo++
		if(this.pagenum>this.order.pageNo){
			
			   setTimeout(() => {
			     this.status = "loadmore";
			   }, 800);
		}else{
			setTimeout(() => {
			  this.status = "nomore";
			}, 800);
		}
		
	
	//     if (res.page.list && res.page.list.length >= this.order.size) {
	//       this.order.pageNo++;
	//       setTimeout(() => {
	//         this.status = "loadmore";
	//       }, 800);
	//       return;
	//     }
	
	//     if (this.orderList.length <= this.order.pageSize) {
	//       this.order.pageNo++;
	//       setTimeout(() => {
	//         this.status = "loadmore";
	//       }, 800);
	//     } else if (
	//       res.orderList.length !== 0 &&
	//       res.orderList.length < this.order.pageSize
	//     ) {
	//       this.order.pageNo++;
	//       setTimeout(() => {
	//         this.status = "loadmore";
	//       }, 800);
	//       return;
	//     }
	  } else {
	    this.show = false;
	  }
	},
	

    //请求订单
    async myOrder() {
      this.status = "loading";
	  this.showlogin=false
       //获取订单的状态
	   console.log(this.swiperCurrent,"this.swiperCurrent")
	   if(this.swiperCurrent==0){
		    this.order.orderStats="" 
	   }else if(this.swiperCurrent==1){
		   this.order.orderStats=0
	   }
	   else if(this.swiperCurrent==2){
	   		   this.order.orderStats=1
	   }
	   else if(this.swiperCurrent==3){
	   		   this.order.orderStats=2
	   }
	   else if(this.swiperCurrent==4){
	   		   this.order.orderStats=3
	   }
	   else if(this.swiperCurrent==5){
	   		   this.order.orderStats=-1
	   }
      	 
      const res = await getGoodsOrderPage(JSON.stringify(this.order));
      if (res.result == 0) {
        this.show = true;
		 this.showlogin=true
        //保存原数组
        // this.orderList = res.page.list;
		this.orderList.push(...res.page.list);
		console.log(this.orderList)

       this.pagenum=Math.ceil(res.page.count/this.order.pageSize)
       this.order.pageNo++
       if(this.pagenum>this.order.pageNo){
       	
		setTimeout(() => {
		  this.status = "loadmore";
		}, 800);
       }else{
		   setTimeout(() => {
		     this.status = "nomore";
		   }, 800);
	   }
        // if (res.page.list && res.page.list.length >= this.order.size) {
        //   this.order.pageNo++;
        //   setTimeout(() => {
        //     this.status = "loadmore";
        //   }, 800);
        //   return;
        // }

        // if (this.orderList.length <= this.order.pageSize) {
        //   this.order.pageNo++;
        //   setTimeout(() => {
        //     this.status = "loadmore";
        //   }, 800);
        // } else if (
        //   res.orderList.length !== 0 &&
        //   res.orderList.length < this.order.pageSize
        // ) {
        //   this.order.pageNo++;
        //   setTimeout(() => {
        //     this.status = "loadmore";
        //   }, 800);
        //   return;
        // }
      } else {
        this.show = false;
      }
    },

    //点击组件触发上拉加载
    loadNextFn() {
      console.log("点击组件触发上拉加载2123");
      //请求订单
      this.myOrder();
    },
    // tab栏切换
    change(index) {
      console.log(index, "tab切换");
	    this.orderList=[]
		this.order.pageNo=1
      this.swiperCurrent = index.index;
	
      //切换状态重新请求
      // this.myOrder()
    },
    // swiper-item左右移动，通知tabs的滑块跟随移动
    transition({ detail: { dx } }) {
      // this.$refs.tabs.setDx(dx);
    },
    // 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
    // swiper滑动结束，分别设置tabs和swiper的状态
    animationfinish({ detail: { current } }) {
      console.log(current, "位置索引");
      // this.$refs.tabs.setFinishCurrent(current);
      this.current = current;
      this.swiperCurrent = current;
      //切换状态重新请求
      // this.myOrder()
    },

    // scroll-view到底部加载更多
    onreachBottom() {
      console.log("到底部 加载更多");
      //请求订单
      this.myOrder();
    },

    //查看物流
    logisticsFn(item, index) {
      console.log(item, index, "物流");
      uni.navigateTo({
        url: `/pages/subpackage/logistics/index?orderId=${item.id}`,
      });
    },
	//门店订单操作
	cancellationtwoFn(item, index, num) {
      if (num === "-2") return;
      if (num === -1) {
        this.showModelContent = "是否确认删除门店订单？";
        this.showModel = true;
        this.orderUpdata = { ...item, index, num };
        return;
      }
     

      if (num === 4) {
        this.showModelContent = "确定要取消门店订单吗？";
      } else if (num === 5) {
        this.showModelContent = "是否确定申请退款门店订单？";
        const order = { ...item, index, num };
			
		if(this.selectorderindex==0){
			uni.navigateTo({
			  url: `/pages/subpackage/apply_afterSale/shopindex?goodsOrderItemId=${encodeURIComponent(
			    JSON.stringify(order)
			  )}`,
			});
		}else if(this.selectorderindex==1){
			uni.navigateTo({
			  url: `/pages/subpackage/apply_afterSale/index?goodsOrderItemId=${encodeURIComponent(
			    JSON.stringify(order)
			  )}`,
			});
		}
        
      } 
	  
      if (num !== 5) {
        this.showModel = true;
      }
      this.orderUpdata = { ...item, index, num };
      console.log(this.orderUpdata, "orderUpdata 状态");
      console.log(this.orderFilter, "更新");
    },

    //取消订单
    cancellationFn(item, index, num) {
      console.log(this.swiperCurrent, "this.swiperCurrent liang");
      if (num === "-2") return;
      if (num === -1) {
        this.showModelContent = "是否确认删除订单？";
        this.showModel = true;
        this.orderUpdata = { ...item, index, num };
        return;
      }
      if (num === -3) {
        this.showModelContent = "是否确认取消售后？";
        this.showModel = true;
        this.orderUpdata = { ...item, index, num };
        return;
      }

      if (num === 4) {
        this.showModelContent = "确定要取消订单吗？";
      } else if (num === 5) {
        this.showModelContent = "是否确定申请退款？";
        const order = { ...item, index, num };
        uni.navigateTo({
          url: `/pages/subpackage/apply_afterSale/index?goodsOrderItemId=${encodeURIComponent(
            JSON.stringify(order)
          )}`,
        });
      } else if (num === 3) {
        this.showModelContent = "是否确定收货？";
      }
	  
      if (num !== 5) {
        this.showModel = true;
      }
      this.orderUpdata = { ...item, index, num };
      console.log(this.orderUpdata, "orderUpdata 状态");
      console.log(this.orderFilter, "更新");
    },
	cancelfun(){
		this.showModel = false;
	},
    //弹窗确认按钮
    async confirm() {
      this.showModel = false;
      const { id,num,index } = this.orderUpdata;
	  console.log(id,num,"訂單")

		 
     if(this.selectorderindex==0){
		 
		 // if (num == "-1") {
		 		  
		 //   //删除订单
		 //   const res = await delGoodsOrder({orderId:id});
		 //   console.log(res, "删除订单");
		 //   if (res.result == 0) {
		 //     //根据index删除数组中取消的那一项
		 //     this.orderList.splice(index, 1);
		 //     uni.showToast({
		 //       title: `删除成功`,
		 //       icon: "success",
		 //       duration: 2000,
		 //     });
		 //   }
		 //   return;
		 // }
		 if(num == "4"){
		 		  //删除订单
		 		   // this.orderFilter.splice(index, 1);
		 		  
		 		   
		 		   
		 		  const res = await cancelPackageOrderPay({packageOrderId:id});
		 		  if (res.result == 0) {
		 		    //根据index删除数组中取消的那一项
		 		   
		 		    uni.showToast({
		 		      title: `订单取消成功`,
		 		      icon: "success",
		 		      duration: 2000,
		 		    });
		 			setTimeout(()=>{
						this.order.pageNo=1
		 				 this.myPackageOrder();
		 			},1000)	
		 		  }
		 		  return;
		 		  
		 }
		 
		 // if(num == "3"){
		 // 		  const res = await confirmGoodsOrderArrival({orderId:id});
		 // 		  if (res.result == 0) {
		 // 		    //根据index删除数组中取消的那一项
		 		  
		 // 		    uni.showToast({	
		 // 		      title: `已确认收货`,
		 // 		      icon: "success",
		 // 		      duration: 2000,
		 // 		    });
		 // 				setTimeout(()=>{
		 // 					 this.myOrder();
		 // 				},1000)
		 				  
		 // 		  }
		 			 
		 // 		  return;
		 		  
		 // }
	 }
if(this.selectorderindex==1){
	if (num == "-1") {
			  
	  //删除订单
	  const res = await delGoodsOrder({orderId:id});
	  console.log(res, "删除订单");
	  if (res.result == 0) {
	    //根据index删除数组中取消的那一项
	    this.orderList.splice(index, 1);
	    uni.showToast({
	      title: `删除成功`,
	      icon: "success",
	      duration: 2000,
	    });
	  }
	  return;
	}
	if(num == "4"){
			  //删除订单
			   // this.orderFilter.splice(index, 1);
			  
			   
			   
			  const res = await cancelGoodsOrder({orderId:id});
			  if (res.result == 0) {
			    //根据index删除数组中取消的那一项
			   
			    uni.showToast({
			      title: `订单取消成功`,
			      icon: "success",
			      duration: 2000,
			    });
				setTimeout(()=>{
					this.order.pageNo=1
					this.orderList=[]
					 this.myOrder();
				},1000)	
			  }
			  return;
			  
	}
	
	if(num == "3"){
			  //删除订单
			   // this.orderFilter.splice(index, 1);
			  
			   
			   
			  const res = await confirmGoodsOrderArrival({orderId:id});
			  if (res.result == 0) {
			    //根据index删除数组中取消的那一项
			  
			    uni.showToast({	
			      title: `已确认收货`,
			      icon: "success",
			      duration: 2000,
			    });
					setTimeout(()=>{
						this.order.pageNo=1
						this.orderList=[]
						 this.myOrder();
					},1000)
					  
			  }
				 
			  return;
			  
	}
}
     
	  

      // //确认收货状态：0->未确认；1->已确认
      // const confirmToggle = confirmStatus && confirmStatus > 0 ? 1 : 0;
      // //确认收货时间
      // const time = new Date().getTime();
      // console.log(time, "time");
      // const data = {
      //   orderSn,
      //   status: num,
      //   confirmStatus: confirmStatus && confirmStatus > 0 ? 1 : 0,
      //   receiveTime: confirmToggle === 1 ? time : "",
      // };
      // const prompt = {
      //   5: "申请已提交",
      //   4: "取消订单成功",
      //   3: "确认收货成功",
      // };
      // let res = {};

      // res = await updateOrderStatusByOrderSn(data);
      // if (res.code === 0) {
      //   //根据index删除数组中取消的那一项
      //   console.log(index, "取消订单");
      //   this.orderFilter.splice(index, 1);
      //   if (num !== 4) {
      //     this.order.pageNo = 1;
      //     this.orderFilter = [];
      //     this.current = num + 1;
      //     this.swiperCurrent = num + 1;
      //     // await this.myOrder();
      //   }
      //   uni.showToast({
      //     title: `${prompt[num]}`,
      //     icon: "success",
      //     duration: 2000,
      //   });
      // }
    },
  },
};
</script>

<style>
/* #ifndef H5 */
page {
  height: 100vh;
  background-color: #f2f2f2;
}
/* #endif */
</style>

<style lang="scss" scoped>
page {
  min-height: 100vh;
 
  overflow: auto;
}

.wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  width: 100%;
   background-color: #ffffff !important;
  .top_select{
	  width: 80%;
	  box-sizing: border-box;
	  padding: 0 40rpx;
	  display: flex;
	  justify-content: space-between;
	  padding-top: 42rpx;
	  .top_type{
		  width: 211rpx;
		  height: 58rpx;
		  border-radius: 15rpx;
		  text-align: center;
		  line-height: 58rpx;
		  box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(1,7,19,0.3);
		  color: #939393;
		  
	  }
	  .select-type{
		  background-color: #FA623D;
		  color: #FFFFFF;
		  
	  }
  }
}

.swiper-box::v-deep {
  height: 100%;
  background-color: #ffffff;
  .swiper-item {
    //height: 1000px;
    //padding-top: rpx(12);
    height:calc(100vh - 180rpx);
    padding-bottom: rpx(16);
    .scroll_wrapper {
      height: 100% !important;
	  
      //padding: rpx(12) rpx(12) rpx(0) rpx(12);
      view.order_wrapper {
        margin: rpx(8) auto rpx(8) auto;
        //margin-bottom: rpx(8);
        width: rpx(351);
        height:auto;
        background: #ffffff;
        border-radius: rpx(5);
        padding: rpx(12);
        .title_wrapper {
          display: flex;
          justify-content: space-between;
          margin-bottom: rpx(8);
          .left_ {
            display: flex;
            align-items: center;
            > image {
              width: rpx(14);
              height: rpx(14);
              margin-right: rpx(4);
              vertical-align: middle;
            }
            .text {
              font-size: rpx(13);
              font-weight: 400;
              color: #353535;
            }
          }
          .right_ {
            font-size: rpx(13);
            font-weight: bold;
            color: #fa5151;
          }
        }
        > .order_info_wrapper {
          display: flex;
		  margin-top: rpx(10);
          > image {
            width: rpx(72);
            height: rpx(72);
          }
          > .right_wrapper {
            flex: 1;
            margin-left: rpx(6);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            > view {
              display: flex;
            }
            > .item_1 {
              justify-content: space-between;
              margin-bottom: rpx(3);
              view:first-child {
                //width: rpx(168);
                font-size: rpx(12);
                font-weight: 400;
                color: #353535;
                overflow: hidden;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2; /*最大行数*/
              }
              view:last-child {
                margin-left: rpx(5);
              }
            }
            > .item_2 {
              display: flex;
              margin-bottom: rpx(4);
              > view {
                //height: rpx(16);
                background: rgba(250, 81, 81, 0.1);
                border-radius: rpx(2);
                border: rpx(1) solid #fa5151;
                font-size: rpx(10);
                padding: rpx(1) rpx(3);
                font-weight: 400;
                color: #fa5151;
              }
            }
            > .item_3 {
              font-size: rpx(12);
              font-weight: 400;
              color: #888888;
              display: flex;
              align-items: center;
              justify-content: space-between;
            }
          }
        }
        > .money_wrapper {
          display: flex;
          margin-top: rpx(8);
          > view {
            margin-left: auto;
            display: flex;
            color: #353535;
            font-size: rpx(12);
            view:first-child {
              margin-right: rpx(10);
            }
            view:last-child {
              > text {
                color: #fa5151;
              }
            }
          }
        }
        > .but_wrapper {
          display: flex;
          margin-top: rpx(12);
          .left_wrapper {
            display: flex;
            align-items: center;
          }
          > view.right_wrapper {
            display: flex;
            margin-left: auto;
            //background: red;
            view {
              //width: rpx(88);
              //height: rpx(32);
              padding: rpx(5) rpx(12);
              border-radius: rpx(16);
              border: rpx(1) solid #dddddd;
              display: flex;
              align-items: center;
              justify-content: center;
              font-size: rpx(15);
              font-weight: 400;
              color: #888888;
              &:not(:last-child) {
                margin-right: rpx(8);
              }
              &.success_wrapper {
                background: #1ab394;
                color: #ffffff;
                border: none;
              }
              &.cancelRefund {
                background: #fa9d3b;
                color: #ffffff;
                font-size: rpx(13);
                border: none;
              }

              &.error_wrapper {
                background: red;
                color: #ffffff;
                border: none;
              }
            }
            .refund_wrapper{
              color: #ffffff;
              font-size: rpx(13);
              background: #169BD5;
            }
            > .confirm_ {
              border: rpx(1) solid #fa5151;
              color: #fa5151;
            }
            > .payment_ {
              color: #ffffff;
              background: #fa5151;
            }
          }
        }
      }
    }
  }
}
.u-tabs-box{
	width: 100%;
	text-align: center;
    margin-top: 23rpx;
	
	
}

/*修改tabs 的样式*/
.u-tabs-box::v-deep {
  .u-tabs {
    //background: pink !important;
    padding: rpx(0) rpx(0);
  }
}

.none_shopping {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 20vh;
  > text {
    font-size: rpx(13);
    font-weight: 400;
    color: #b2b2b2;
  }
  > image {
    width: rpx(222);
    height: rpx(158);
  }
}
	
.order-k{
	width: 686rpx;
	// height: 336rpx;
	background: #FFFFFF;
	opacity: 1;
	box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(1,7,19,0.3);
	border-radius: 15rpx;
	margin: 0 auto 25rpx;
	padding: 52rpx 33rpx 20rpx;
	.order-title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 25rpx;
		color: #7F7E7E;
		line-height: 35rpx;
		.order-title-left{
			overflow: hidden;
			  text-overflow: ellipsis;
			  white-space: nowrap;
		}
		.order-title-right{
			margin-left: 20rpx;
			 white-space: nowrap;
		}
	}
	.order-pages-info{
		display: flex;
	}
	.order-info{
		// display: flex;
		margin-top: 15rpx;
		.order-info-k{
			display: flex;
			
		}
		.order-shouh{
			display: flex;
			justify-content: flex-end;
			margin-top: 10rpx;
			.order-shouh-item{
				width: 150rpx;
				border: 1rpx solid #333333;
				border-radius: 25rpx;
				height: 50rpx;
				font-size: 25rpx;
				line-height: 50rpx;
				margin-left: 20rpx;
				text-align: center;
			}
			.order-shouh-item-true{
				border: none;
				color: red;
			}
		}
		
		.order-info-icon{
			width: 120rpx;
			height: 120rpx;
			image{
				width: 120rpx;
				height: 120rpx;
			}
		}
		.order-info-content{
			margin-left: 37rpx;
			.order-info-name{
				font-size: 25rpx;
				overflow: hidden;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2; /*最大行数*/
			}
			.order-info-content-time{
				font-size: 25rpx;
				color: #333333;
				line-height: 35rpx;
				margin-top: 10rpx;
				
			}
			.order-info-content-time-shop{
				display: flex;
				justify-content: flex-start;
				.order-info-content-time-shop-left{
					white-space: nowrap;
				}
			}
				
			.order-info-content-mrs{
				font-size: 25rpx;
				color: #333333;
				line-height: 35rpx;
				margin-top: 9rpx;
			}
			.shop-order-info-content-mrs{
				display: flex;
				justify-content: space-between;
				.shop-order-info-content-mrs-text{
					margin-left: 20rpx;
				}
			}
		}
	}
	.order-num{
		display: flex;
		align-items: center;
		font-size: 44rpx;
		margin-top: 55rpx;
		color: #1E3249;
		line-height: 62rpx;
	}
	.order-num view:nth-child(1){
		font-size: 22rpx;
		color: #1E3249;
		line-height: 31rpx;
	}
	.order-num view:nth-child(3){
		font-size: 22rpx;
		color: #1E3249;
		line-height: 31rpx;
	}
	.order-num-shop{
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 44rpx;
		margin-top: 55rpx;
		color: #1E3249;
		line-height: 62rpx;
	}
	.order-num-sl{
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}
	.order-num-sl view:nth-child(1){
		font-size: 22rpx;
		color: #1E3249;
		line-height: 31rpx;
	}
	.order-num-sl view:nth-child(2){
		font-size: 44rpx;
		color: #1E3249;
		line-height: 31rpx;
	}
	.order-num-time{
		font-size: 22rpx;
	}
	
}
.order-czbt{
	width: 100%;
	display: flex;
	justify-content: flex-end;
	margin-top: 10rpx;
	.order-czbt-item{
		width: 150rpx;
		border: 1rpx solid #333333;
		border-radius: 25rpx;
		height: 50rpx;
		font-size: 25rpx;
		line-height: 50rpx;
		margin-left: 20rpx;
		text-align: center;
	}
}
</style>
